package com.rq.adapter;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.rq.rvlibrary.BaseAdapter;
import com.rq.rvlibrary.BaseViewHolder;
import com.rq.rvlibrary.EasyViewHolder;
import com.rq.rvlibrary.NestingBuilder;
import com.rq.rvlibrary.RecyclerUtil;

import java.util.ArrayList;
import java.util.List;

public class DoubleAct extends Activity {
    BaseAdapter doubleAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.recycler_dou);
        RecyclerView recyclerView = findViewById(R.id.recycler);
        doubleAdapter = new BaseAdapter(this, R.layout.item_parent, DRVH.class);
//        doubleAdapter = new BaseAdapter(this, new NestingBuilder(R.layout.item_parent, R.layout.item_child, R.id.recycler_inner) {
//
//            @Override
//            public List getChildData(Object parentBean, int position) {
////                return (List) parentBean;
//                return ((DebugData2) parentBean).childData;
//            }
//
//            @Override
//            public void fillChildData(EasyViewHolder holder, int position, Object childBean, int pPostion) {
//                super.fillChildData(holder, position, childBean, pPostion);
////                DebugData item = (DebugData) childBean;
////                holder.setItemText(R.id.text_time, item.time);
////                holder.setItemText(R.id.text_ml, item.num);
//
//                String item = (String) childBean;
//                holder.setItemText(R.id.text_time, item + "X");
//                holder.setItemText(R.id.text_ml, item + "Y");
//            }
//
//            @Override
//            public void fillParentData(BaseViewHolder holder, BaseAdapter parentAdapter, int position, Object parentBean, BaseAdapter childAdapter, boolean showChild) {
//                super.fillParentData(holder, parentAdapter, position, parentBean, childAdapter, showChild);
////                holder.setItemText(R.id.text_type, ((List)parentBean).size()+"-->");
//
//                DebugData2 pData = (DebugData2) parentBean;
//                holder.setItemText(R.id.text_type, pData.outData);
//            }
//
//            @Override
//            public RecyclerUtil getChildRecyclerUtil(BaseAdapter adapter) {
//                return new RecyclerUtil(adapter).horizontal();
//            }
//        });
        new RecyclerUtil(doubleAdapter).set2View(recyclerView);

//        List<List<DebugData>> lists = new ArrayList<>();
//        for (int i = 0; i < 12; i++) {
//            List<DebugData> data = new ArrayList<>();
//            for (int j = 0; j < 4; j++) {
//                data.add(new DebugData(i, j));
//            }
//            lists.add(data);
//        }

        List<DebugData2> lists = new ArrayList<>();
        for (int i = 0; i < 12; i++) {
            DebugData2 data = new DebugData2();
            data.outData = "Parent" + i;
            data.childData = new ArrayList<>();
            for (int j = 0; j < 4; j++) {
                data.childData.add("Child" + j);
            }
            lists.add(data);
        }
        doubleAdapter.setData(lists);

    }

    public class DebugData2 {
        String outData;
        List<String> childData;
    }
}
